import http.client

#   建立连接
conn = http.client.HTTPConnection('localhost')
#   构建正文
param = 'name=admin&password=password&verifyCode='
#   构建头部
header = {'Content-Type': 'application/x-www-form-urlencoded',
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
#   发送POST请求
conn.request('POST', '/TinyShop17/index.php?con=admin&act=check', param, header)
#   获取响应内容
response = conn.getresponse()
print(response.code, response.reason)
print(response.read().decode())

# 很奇怪, tinyshop用代码来实现的话, 验证码带上就会登陆不成功.不带验证码就登陆成功了.
# http.client不会自动处理重定向的请求
